home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / ru01.zip / DISXGF.C < prev    next >
C/C++ Source or Header  |  1993-06-11  |  2KB  |  74 lines

  1. /* ************************************************************ */
  2. /* disxgf.c For Turbo C - Demonstrates how to display XGF files */
  3. /*              that are larger than 64K              */
  4. /*                                                              */
  5. /* Use Raster Clip/Rastport to convert PCX files to XGF format. */
  6. /*                                                              */
  7. /* ************************************************************ */
  8.  
  9. #include <stdio.h>
  10. #include <graphics.h>
  11.  
  12.  
  13. int huge DetectVGA256(void)
  14. {
  15.  return(0);   /* change 0 to other value for SVGA modes */
  16. }
  17.  
  18. void setvga256(void)
  19. {
  20.  int gm,driver = DETECT;
  21.  installuserdriver("svga256",DetectVGA256);
  22.  initgraph(&driver,&gm,"");
  23. }
  24.  
  25. void setvga16()
  26. {
  27.  int driver = VGA,
  28.      mode = VGALO;
  29.  
  30.  initgraph(&driver, &mode, "");
  31. }
  32.  
  33. void dis_xgf(int x, int y, char *filename)
  34. {
  35.  FILE *F;
  36.  unsigned int width,height,bpl,i;
  37.  int scanline[1030];
  38.  
  39.  F=fopen(filename,"rb");
  40.  if (F!=NULL)
  41.  {
  42.    fread(&width,2,1,F);
  43.    fread(&height,2,1,F);
  44.    scanline[0]=width;
  45.    scanline[1]=0;
  46.    if (getmaxcolor()==255)
  47.    {
  48.      bpl=width+1;
  49.    }
  50.    else
  51.    {
  52.      bpl=imagesize(0,0,width,0)-6;
  53.    }
  54.    for(i=0;i<height;i++)
  55.    {
  56.      fread(&scanline[2],1,bpl,F);
  57.      putimage(x,y+i,scanline,0);
  58.    }
  59.    fclose(F);
  60.  }
  61. }
  62.  
  63.  
  64. void main()
  65. {
  66.   setvga16();          /* replace with setvga256 for 256 color XGF files */
  67.  
  68.   setfillstyle(SOLID_FILL,BLUE);
  69.   bar(0,0,getmaxx(),getmaxy());
  70.   dis_xgf(0,0,"image.xgf");
  71.   getch();
  72.   closegraph();
  73. }
  74.